package main

import (
	"encoding/json"
	"fmt"
	"net/http"
)

type Tip struct {
	Word        string `json:"w"`
	Translation string `json:"t"`
}

type Tips struct {
	Tips []Tip `json:"tips"`
}

func GetTips(abc string) ([]Tip, error) {
	r, err := http.Get(fmt.Sprintf("https://wooordhunt.ru/openscripts/forjs/get_tips.php?abc=%s", abc))

	if err != nil {
		return nil, err
	}

	defer r.Body.Close()

	var tips Tips

	if err := json.NewDecoder(r.Body).Decode(&tips); err != nil {
		return nil, err
	}

	return tips.Tips, nil
}
